import React, { useEffect, useState } from 'react'
import PubSub from 'pubsub-js'
import Item from "./Item"

export default function List() {
  const [searchList, setSearchList] = useState([])
  // 初始化的时候渲染数据
  useEffect(() => {
    PubSub.subscribe("github", (_, data) => {
      setSearchList(data.data.items)
      console.log(data);
    })


  }, [])
  return (
    <div className="row">
      {
        searchList.map(item => {
          return <Item key={item.id}{...item} />
        })
      }
    </div>
  )
}
